<template>
	<view class="profile">
		<cu-custom bgColor="bg-gradual-orange" :isBack="true">
			<block slot="content">活动配置</block>
		</cu-custom>
		<view class="cu-form-group">
			<view class="title">商户实收比例</view>
			<input v-model="form.discount_fee"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">订单参与门槛</view>
			<input v-model="form.min_rebate_money"></input>
		</view>


		<view class="padding flex flex-direction">
			<button class="cu-btn bg-gradual-orange margin-tb-sm lg" @tap="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import shop from '@/api/shop';
	export default {
		data() {
			return {
				form: {
					discount_fee: '',
					min_rebate_money: '',
				},
				info: {}
			}
		},
		computed: {
			...mapState(['userInfo']),
		},
		onLoad() {
			this.loadInfo();
		},
		methods: {
			async loadInfo() {
				shop.profile().then(res => {
					if (res.code === 1) {
						this.info = res.data;
						if(this.info){
							this.form.discount_fee = this.info.discount_fee;
							this.form.min_rebate_money = this.info.min_rebate_money;
						}
					} else {
						this.toast(res.msg);
					}
				})
			},
			submit() {
				if (this.loading) {
					return;
				}
				this.loading = true;
				setTimeout(() => {
					this.loading = false
				}, 7000)
                
				console.log(this.form)
				
				shop.settingUpdate(this.form).then(res => {
					this.loading = false;
					this.toast(res.msg);
				})
			},
		}
	}
</script>

<style>

</style>